//package com.bs.listen;
//
//import lombok.extern.log4j.Log4j2;
//import org.apache.kafka.clients.producer.ProducerRecord;
//import org.apache.kafka.clients.producer.RecordMetadata;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.kafka.core.KafkaTemplate;
//import org.springframework.kafka.support.ProducerListener;
//
//import javax.annotation.PostConstruct;
//import javax.annotation.Resource;
//
///**
// * @author bingshao
// * @date 2022/11/14
// **/
//@Configuration
//@Log4j2
//public class KafkaListener {
//
//    @Resource
//    private KafkaTemplate<String, Object> kafkaTemplate;
//
//    /**
//     * 配置监听
//     */
//    @PostConstruct
//    private void listener() {
//        kafkaTemplate.setProducerListener(new ProducerListener<String, Object>() {
//
//            @Override
//            public void onSuccess(ProducerRecord<String, Object> producerRecord, RecordMetadata recordMetadata) {
//                String topic = recordMetadata.topic();
//                int partition = recordMetadata.partition();
//                long offset = recordMetadata.offset();
//                log.info("成功====》主题：" + topic + "=====>分区:" + partition + "=====>位移:" + offset);
//            }
//
//            @Override
//            public void onError(ProducerRecord<String, Object> producerRecord, RecordMetadata recordMetadata, Exception exception) {
//                log.error("错误原因==============》" + exception.getMessage());
//            }
//        });
//
//    }
//
//
//}
